//
//  bianjianpaiViewController.m
//  shifaOASystem
//
//  Created by michael on 2018/1/5.
//  Copyright © 2018年 czd. All rights reserved.
//
#import "bianjiTableViewCell.h"
#import "bianjianpaiViewController.h"
#import "GDataDefines.h"
#import "UnDoneModel.h"
#import "OADetailViewController.h"
#import "OADetailDisPatchController.h"
#import "OAUnDoneListCell.h"
#import "PickerChoiceView.h"
#import "TableViewCell.h"
@interface bianjianpaiViewController ()<UITableViewDelegate,UITableViewDataSource,TFPickerDelegate,UITextFieldDelegate,UITextViewDelegate>
{
    NSInteger selectIndex;
}
@property(nonatomic,strong)NSMutableArray * dataArray;
@property(nonatomic,assign)int totalCounts; //总条数
@property(nonatomic,assign)int currentPage; //当前页
@property (nonatomic,strong)NSMutableArray *numArray;

@property (nonatomic,strong)NSMutableArray *mutArray;
@property (nonatomic,strong)NSMutableArray *Array;

@property (nonatomic,strong)NSArray *numberarray;
@property (nonatomic,strong)NSArray *weekarray;
@end

@implementation bianjianpaiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//      [self requestdata];
// [self loadData];
       _tableview = [[UITableView alloc]initWithFrame:CGRectMake(0,0, KScreenWidth, KScreenHeight-kTopHeight) style:UITableViewStylePlain];
        self.tableview.separatorStyle = UITableViewCellSeparatorStyleNone;

    _tableview.dataSource = self;
    _tableview.delegate = self;
    if([_type isEqualToString:@"xinjian"]){
        self.title = @"新建";
    }else{
    
        self.title = @"编辑";

    }
    [self.view addSubview:_tableview];
    _weekarray =  @[@"星期一",@"星期二",@"星期三",@"星期四",@"星期五",@"星期六",@"星期日"];
      // 分类搜索
    _array = _Array;
  _numberarray = _numberArray;
  UINib *nib = [UINib nibWithNibName:@"TableViewCell" bundle:nil];
    [self.tableview registerNib:nib forCellReuseIdentifier:@"TableViewCellID"];
    _method = @"contentLeader";
    _url = kexchleader;
 
     UIBarButtonItem * rightIem = [[UIBarButtonItem alloc] initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:self action:@selector(searchAction)];
        self.navigationItem.rightBarButtonItem = rightIem;
    // Do any additional setup after loading the view.
}
-(void)searchAction{
[self.view endEditing:YES];
// 新建
NSString *json =[NSString stringWithFormat: @"{'MonAM':'%@','MonPM':'%@', 'TuesAM':'%@','TuesPM':'%@','WedAM':'%@','WedPM':'%@','ThurAM':'%@','ThurPM':'%@','FriAM':'%@','FriPM':'%@','SatAM':'%@','SatPM':'%@','SunAM':'%@','SunPM':'%@'}",_monField1.text,_monField2.text,_TuesField1.text,_TuesField2.text,_WedField1.text,self.WedField2.text,_ThurField1.text,_TuesField2.text,_FriField1.text,_FriField2.text,_SaturField1.text,_SaturField2.text,_SunField1.text,_SunField2.text];
//为发发身披战衣鱼翅9999999999，抬起头才发现你以为是忘了谁

     NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
if([_type isEqualToString:@"xinjian"]){
    NSArray * array =@[@{@"sName":userId},@{@"json":json}];
    NSLog(@"%@",array);

    }else{
    
    
    }
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    //get cell
//    UITableViewCell *cell  = (UITableViewCell *)[[textField superview] superview];
//    NSIndexPath *indexPath = [tableView indexPathForCell:cell];

}
- (void)requestdata{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];

NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSArray * array = @[@{@"unid":@"xxx"},@{@"userId":userId}];
    [HttpTools requestWithURL:kexchleader arrays:array method:@"getLeader" success:^(id JSON) {
                [MBProgressHUD hideAllHUDsForView:self.view animated:YES];

     NSArray *array = JSON [@"data"];
     _Array = [NSMutableArray array];
     _numberArray = [NSMutableArray array];
          _numArray = [NSMutableArray array];

     for (NSDictionary *dic in array) {
    NSString *leader = dic[@"leader"];
     NSString *number = dic[@"number"];
    [_Array addObject:leader];
    [_numberArray addObject:number];
        [_numArray addObject: dic];

}
_array = _Array;
_numberarray = _numberArray;
   self.mutArray = [NSMutableArray array];

  NSArray *arr = @[@{@"title1":@"请点击此处选择类别",@"title2":_array [0]  }];
    for (NSDictionary *dict in arr) {
        
        [self.mutArray addObject:dict];
    }

//_name = _Array[0];
//_number = _numberarray[0];

//   [self loadData];
  
        [self.tableview reloadData];
                    } failure:^(NSError *error) {
        [self.tableview headerEndRefreshing];
                    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];

        
        
    }];

}
- (void)loadData{
 _method = @"contentLeader";
    _url = kexchleader;
    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
//
[MBProgressHUD showHUDAddedTo:self.view animated:YES];

NSArray  *array = @[@{@"unId":_name},@{@"leader":_name},@{@"number":_number},@{@"userId":userId}];

 [HttpTools requestWithURL:self.url arrays: array method:_method success:^(id JSON) {
            [MBProgressHUD hideAllHUDsForView:self.view animated:YES];

  NSLog(@"%@",JSON);

     
    NSArray *array = JSON [@"result"];
 NSMutableArray  *Array = [NSMutableArray array];

     for (NSDictionary *dict in array) {
         NSArray *array2 =dict[@"data"];

    NSDictionary *dic = [array2 firstObject];

    [Array addObject:dic];
}
_dataArray = Array;

   
   
   
                [self.tableview reloadData];
    } failure:^(NSError *error) {
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    }];




}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//if(indexPath.row==0)
//{
//return 40;
//}
//else{
   NSDictionary *dic = _dataArray[indexPath.row ];
    CGFloat height = 0;
CGFloat  titlesize1;
CGFloat  titlesize2;
if(dic.count!=0){
titlesize1  = [OAToolBox sizebyText:dic[@"morning"] font:13 minsWidth:60];
  titlesize2  = [OAToolBox sizebyText:dic[@"afternoon"] font:13 minsWidth:60];
//    CGFloat  titlesize = titlesize2 +titlesize1;
    }else{
 titlesize1 = 30;
  titlesize2 = 30;
    
    }
//    NSString * desstring = [NSString stringWithFormat:@"%@",model.time];
//    CGFloat dessize = [OAToolBox sizebyText:desstring font:13 minsWidth:60];;
if(titlesize2>30){

}else{
titlesize2 = 30;

}
if(titlesize1>30){

}else{
titlesize1 = 30;

}
    CGFloat  titlesize = titlesize2 +titlesize1;//

    if (titlesize <  60) {
    return 100+10;
}
else{
 return  titlesize+40+10;

}
    
//   }
}




#pragma mark UITableView dataScource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

//if (indexPath.row==0) {
//    NSDictionary *dict = [self.mutArray objectAtIndex:0];
//
//    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableViewCellID"];
//    cell.leftLb.text = dict[@"title1"];
//    cell.rightLb.text = dict[@"title2"];
//   return cell;
//}
 
 
if(indexPath.row ==0){
static NSString *cellid11 = @"cell11";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid11];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
                 NSDictionary *dic = _dataArray[indexPath.row ];

     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid11];
   UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero];
     UILabel * label1 = [[UILabel alloc]init];
      UILabel * label2 = [[UILabel alloc]init];
        label.frame = CGRectMake(20, 0, 100, 30);


    label.text = [NSString stringWithFormat:@"%@ :", _weekarray[indexPath.row]];
      _monField1 = [[zhucetextfield alloc]init];
              _monField1.delegate = self;
         [cell.contentView addSubview:_monField1];

          _monField2 = [[zhucetextfield alloc]init];
              _monField2.delegate = self;
         [cell.contentView addSubview:_monField2];
CGFloat  titlesize1;
CGFloat  titlesize2;
     if(dic.count!=0){
titlesize1  = [OAToolBox sizebyText:dic[@"morning"] font:13 minsWidth:60];
  titlesize2  = [OAToolBox sizebyText:dic[@"afternoon"] font:13 minsWidth:60];
    }else{
 titlesize1 = 30;
  titlesize2 = 30;

    }
    if(titlesize1>30){
_monField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,titlesize1);
 }
 else{
_monField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,30);
  }
 if(titlesize2>30){
_monField2.frame = CGRectMake(50, _monField1.bottom+10, KScreenWidth-60,titlesize2);
 }
 else{
_monField2.frame = CGRectMake(50, _monField1.bottom+10, KScreenWidth-60,30);
 }
     
 label1.frame = CGRectMake(10, label.bottom, 40,30);
label2.frame = CGRectMake(10, _monField1.bottom+10, 40,30);
    label1.text = [NSString stringWithFormat:@"上午:"];
    label2.text = [NSString stringWithFormat:@"下午:"];
          [cell.contentView addSubview:label];
    [cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];

    }
       if(dic.count!=0){
     _monField1.text =dic[@"morning"];
 _monField2.text =dic[@"afternoon"];

 }

    return cell;
}if(indexPath.row ==1){
             NSDictionary *dic = _dataArray[indexPath.row ];

static NSString *cellid12 = @"cell2";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid12];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid12];
   UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero];
     UILabel * label1 = [[UILabel alloc]init];
      UILabel * label2 = [[UILabel alloc]init];
        label.frame = CGRectMake(20, 0, 100, 30);


    label.text = [NSString stringWithFormat:@"%@ :", _weekarray[indexPath.row ]];
      _TuesField1 = [[zhucetextfield alloc]init];
              _TuesField1.delegate = self;
         [cell.contentView addSubview:_TuesField1];

          _TuesField2 = [[zhucetextfield alloc]init];
              _TuesField2.delegate = self;
         [cell.contentView addSubview:_TuesField2];
CGFloat  titlesize1;
CGFloat  titlesize2;
     if(dic.count!=0){
titlesize1  = [OAToolBox sizebyText:dic[@"morning"] font:13 minsWidth:60];
  titlesize2  = [OAToolBox sizebyText:dic[@"afternoon"] font:13 minsWidth:60];
    }else{
 titlesize1 = 30;
  titlesize2 = 30;

    }
    if(titlesize1>30){
_TuesField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,titlesize1);
 }
 else{
_TuesField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,30);
  }
 if(titlesize2>30){
_TuesField2.frame = CGRectMake(50, _TuesField1.bottom+10, KScreenWidth-60,titlesize2);
 }
 else{
_TuesField2.frame = CGRectMake(50, _TuesField1.bottom+10, KScreenWidth-60,30);
 }
       
 label1.frame = CGRectMake(10, label.bottom, 40,30);
label2.frame = CGRectMake(10, _TuesField1.bottom+10, 40,30);
    label1.text = [NSString stringWithFormat:@"上午:"];
    label2.text = [NSString stringWithFormat:@"下午:"];
          [cell.contentView addSubview:label];
    [cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];

    } if(dic.count!=0){

 _TuesField1.text =dic[@"morning"];
 _TuesField2.text =dic[@"afternoon"];
 }
    return cell;
}
if(indexPath.row ==2){             NSDictionary *dic = _dataArray[indexPath.row ];

static NSString *cellid13 = @"cell3";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid13];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid13];
   UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero];
     UILabel * label1 = [[UILabel alloc]init];
      UILabel * label2 = [[UILabel alloc]init];
        label.frame = CGRectMake(20, 0, 100, 30);


    label.text = [NSString stringWithFormat:@"%@ :", _weekarray[indexPath.row ]];
      _WedField1 = [[zhucetextfield alloc]init];
              _WedField1.delegate = self;
         [cell.contentView addSubview:_WedField1];

          _WedField2 = [[zhucetextfield alloc]init];
              _WedField2.delegate = self;
         [cell.contentView addSubview:_WedField2];
             NSDictionary *dic = _dataArray[indexPath.row - 1];
CGFloat  titlesize1;
CGFloat  titlesize2;
     if(dic.count!=0){
titlesize1  = [OAToolBox sizebyText:dic[@"morning"] font:13 minsWidth:60];
  titlesize2  = [OAToolBox sizebyText:dic[@"afternoon"] font:13 minsWidth:60];
    }else{
 titlesize1 = 30;
  titlesize2 = 30;

    }
    if(titlesize1>30){
_WedField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,titlesize1);
 }
 else{
_WedField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,30);
  }
 if(titlesize2>30){
_WedField2.frame = CGRectMake(50, _WedField1.bottom+10, KScreenWidth-60,titlesize2);
 }
 else{
_WedField2.frame = CGRectMake(50, _WedField1.bottom+10, KScreenWidth-60,30);
 }
      
 label1.frame = CGRectMake(10, label.bottom, 40,30);
label2.frame = CGRectMake(10, _WedField1.bottom+10, 40,30);
    label1.text = [NSString stringWithFormat:@"上午:"];
    label2.text = [NSString stringWithFormat:@"下午:"];
          [cell.contentView addSubview:label];
    [cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];

    }  if(dic.count!=0){

 _WedField1.text =dic[@"morning"];
 _WedField2.text =dic[@"afternoon"];
 }
    return cell;
}if(indexPath.row ==3){             NSDictionary *dic = _dataArray[indexPath.row ];

static NSString *cellid14 = @"cell4";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid14];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid14];
   UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero];
     UILabel * label1 = [[UILabel alloc]init];
      UILabel * label2 = [[UILabel alloc]init];
        label.frame = CGRectMake(20, 0, 100, 30);


    label.text = [NSString stringWithFormat:@"%@ :", _weekarray[indexPath.row ]];
      _ThurField1 = [[zhucetextfield alloc]init];
              _ThurField1.delegate = self;
         [cell.contentView addSubview:_ThurField1];

          _ThurField2 = [[zhucetextfield alloc]init];
              _ThurField2.delegate = self;
         [cell.contentView addSubview:_ThurField2];
CGFloat  titlesize1;
CGFloat  titlesize2;
     if(dic.count!=0){
titlesize1  = [OAToolBox sizebyText:dic[@"morning"] font:13 minsWidth:60];
  titlesize2  = [OAToolBox sizebyText:dic[@"afternoon"] font:13 minsWidth:60];
    }else{
 titlesize1 = 30;
  titlesize2 = 30;

    }
    if(titlesize1>30){
_ThurField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,titlesize1);
 }
 else{
_ThurField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,30);
  }
 if(titlesize2>30){
_ThurField2.frame = CGRectMake(50, _ThurField1.bottom+10, KScreenWidth-60,titlesize2);
 }
 else{
_ThurField2.frame = CGRectMake(50, _ThurField1.bottom+10, KScreenWidth-60,30);
 }
        
 label1.frame = CGRectMake(10, label.bottom, 40,30);
label2.frame = CGRectMake(10, _ThurField1.bottom+10, 40,30);
    label1.text = [NSString stringWithFormat:@"上午:"];
    label2.text = [NSString stringWithFormat:@"下午:"];
          [cell.contentView addSubview:label];
    [cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];

    }if(dic.count!=0){

 _TuesField1.text =dic[@"morning"];
 _TuesField2.text =dic[@"afternoon"];
 }
    return cell;
}if(indexPath.row ==4){             NSDictionary *dic = _dataArray[indexPath.row ];

static NSString *cellid15 = @"cell5";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid15];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid15];
   UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero];
     UILabel * label1 = [[UILabel alloc]init];
      UILabel * label2 = [[UILabel alloc]init];
        label.frame = CGRectMake(20, 0, 100, 30);


    label.text = [NSString stringWithFormat:@"%@ :", _weekarray[indexPath.row ]];
      _FriField1 = [[zhucetextfield alloc]init];
              _FriField1.delegate = self;
         [cell.contentView addSubview:_FriField1];

          _FriField2 = [[zhucetextfield alloc]init];
              _FriField2.delegate = self;
         [cell.contentView addSubview:_FriField2];
             NSDictionary *dic = _dataArray[indexPath.row - 1];
CGFloat  titlesize1;
CGFloat  titlesize2;
     if(dic.count!=0){
titlesize1  = [OAToolBox sizebyText:dic[@"morning"] font:13 minsWidth:60];
  titlesize2  = [OAToolBox sizebyText:dic[@"afternoon"] font:13 minsWidth:60];
    }else{
 titlesize1 = 30;
  titlesize2 = 30;

    }
    if(titlesize1>30){
_FriField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,titlesize1);
 }
 else{
_FriField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,30);
  }
 if(titlesize2>30){
_FriField2.frame = CGRectMake(50, _FriField1.bottom+10, KScreenWidth-60,titlesize2);
 }
 else{
_FriField2.frame = CGRectMake(50, _FriField1.bottom+10, KScreenWidth-60,30);
 }
       
 label1.frame = CGRectMake(10, label.bottom, 40,30);
label2.frame = CGRectMake(10, _FriField1.bottom+10, 40,30);
    label1.text = [NSString stringWithFormat:@"上午:"];
    label2.text = [NSString stringWithFormat:@"下午:"];
          [cell.contentView addSubview:label];
    [cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];

    }if(dic.count!=0){

 _FriField1.text =dic[@"morning"];
 _FriField2.text =dic[@"afternoon"];
 }
    return cell;
    
}if(indexPath.row ==5){             NSDictionary *dic = _dataArray[indexPath.row];

static NSString *cellid16 = @"cell6";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid16];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid16];
   UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero];
     UILabel * label1 = [[UILabel alloc]init];
      UILabel * label2 = [[UILabel alloc]init];
        label.frame = CGRectMake(20, 0, 100, 30);


    label.text = [NSString stringWithFormat:@"%@ :", _weekarray[indexPath.row ]];
      _SaturField1 = [[zhucetextfield alloc]init];
              _SaturField1.delegate = self;
         [cell.contentView addSubview:_SaturField1];

          _SaturField2 = [[zhucetextfield alloc]init];
              _SaturField2.delegate = self;
         [cell.contentView addSubview:_SaturField2];
CGFloat  titlesize1;
CGFloat  titlesize2;
     if(dic.count!=0){
titlesize1  = [OAToolBox sizebyText:dic[@"morning"] font:13 minsWidth:60];
  titlesize2  = [OAToolBox sizebyText:dic[@"afternoon"] font:13 minsWidth:60];
    }else{
 titlesize1 = 30;
  titlesize2 = 30;

    }
    if(titlesize1>30){
_SaturField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,titlesize1);
 }
 else{
_SaturField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,30);
  }
 if(titlesize2>30){
_SaturField2.frame = CGRectMake(50, _SaturField1.bottom+10, KScreenWidth-60,titlesize2);
 }
 else{
_SaturField2.frame = CGRectMake(50, _SaturField1.bottom+10, KScreenWidth-60,30);
 }
       
 label1.frame = CGRectMake(10, label.bottom, 40,30);
label2.frame = CGRectMake(10, _SaturField1.bottom+10, 40,30);
    label1.text = [NSString stringWithFormat:@"上午:"];
    label2.text = [NSString stringWithFormat:@"下午:"];
          [cell.contentView addSubview:label];
    [cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];

    } if(dic.count!=0){

 _SaturField1.text =dic[@"morning"];
 _SaturField2.text =dic[@"afternoon"];
 }
    return cell;
}if(indexPath.row ==6){             NSDictionary *dic = _dataArray[indexPath.row ];

static NSString *cellid17 = @"cell7";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid17];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
  cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid17];
   UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero];
     UILabel * label1 = [[UILabel alloc]init];
      UILabel * label2 = [[UILabel alloc]init];
        label.frame = CGRectMake(20, 0, 100, 30);


    label.text = [NSString stringWithFormat:@"%@ :", _weekarray[indexPath.row ]];
      _SunField1 = [[zhucetextfield alloc]init];
              _SunField1.delegate = self;
         [cell.contentView addSubview:_SunField1];

          _SunField2 = [[zhucetextfield alloc]init];
              _SunField2.delegate = self;
         [cell.contentView addSubview:_SunField2];
CGFloat  titlesize1;
CGFloat  titlesize2;
     if(dic.count!=0){
titlesize1  = [OAToolBox sizebyText:dic[@"morning"] font:13 minsWidth:60];
  titlesize2  = [OAToolBox sizebyText:dic[@"afternoon"] font:13 minsWidth:60];
    }else{
 titlesize1 = 30;
  titlesize2 = 30;

    }
    if(titlesize1>30){
_SunField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,titlesize1);
 }
 else{
_SunField1.frame = CGRectMake(50, label.bottom, KScreenWidth-60,30);
  }
 if(titlesize2>30){
_SunField2.frame = CGRectMake(50, _SunField1.bottom+10, KScreenWidth-60,titlesize2);
 }
 else{
_SunField2.frame = CGRectMake(50, _SunField1.bottom+10, KScreenWidth-60,30);
 }
       
 label1.frame = CGRectMake(10, label.bottom, 40,30);
label2.frame = CGRectMake(10, _SunField1.bottom+10, 40,30);
    label1.text = [NSString stringWithFormat:@"上午:"];
    label2.text = [NSString stringWithFormat:@"下午:"];
          [cell.contentView addSubview:label];
    [cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];

    } if(dic.count!=0){

 _SunField1.text =dic[@"morning"];
 _SunField2.text =dic[@"afternoon"];
 }
    return cell;
}

else{
//
//     static NSString *identifier=@"UITableViewCellIdentifierKey1";
//    bianjiTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
//
//if(!cell){
//        cell=[[bianjiTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
//    }
//
//    cell.week = _weekarray[indexPath.row - 1];
//    cell.dic = _dataArray[indexPath.row - 1];
//    _monField1 = [[zhucetextfield alloc]init];
//        _monField2 = [[zhucetextfield alloc]init];
//
//    if (indexPath.row ==1) {
//   _monField1 =   cell.textfield1;
//   _monField2= cell.textfield1;
//}if (indexPath.row ==2) {
//  _TuesField1  =  cell.textfield1 ;
//   _TuesField2 =  cell.textfield1 ;
//}
//
//
//                  return cell;

return nil;
}
    }



-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

if (indexPath.row == 0){
PickerChoiceView *picker = [[PickerChoiceView alloc]initWithFrame:self.view.bounds];
    selectIndex = indexPath.row;
    picker.type = @"1";
    picker.delegate = self;
    if (indexPath.section == 0) {
        
        picker.selectLb.text = @"选择领导";
        picker.customArr = _array;
    }

    [self.view addSubview:picker];

}else{
nil;
}
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return self.dataArray.count+1;
        return 7;

}
- (void)PickerSelectorIndixString:(NSString *)str:(NSString *)type{

    NSDictionary *dict = [self.mutArray objectAtIndex:0];
    
    NSMutableDictionary *muDict = [NSMutableDictionary dictionaryWithDictionary:dict];
    [muDict setObject:str forKey:@"title2"];
       // [muDict setObject:@"" forKey:@"title1"];
    [self.mutArray replaceObjectAtIndex:0 withObject:muDict];
//    [self.mutArray removeObjectAtIndex:selectIndex];
//    [self.mutArray insertObject:muDict atIndex:selectIndex];
_name = str;
NSInteger index = [_array indexOfObject:str];

_number = _numberarray[index];


    [self loadData];
    NSLog(@"%@,%@",str,_number);
//    [self.tableview reloadData];
    
}
@end

